<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .trail {
            /* className for the trail elements */
            position: absolute;
            height: 6px;
            width: 6px;
            border-radius: 3px;
            background: teal;
        }

        body {
            height: 300px;
        }
    </style>
</head>

<body>
    <script>
        let dots = [];
        for (let i = 0; i < 1000; i++) {
            let node = document.createElement("div");
            node.className = "trail";
            document.body.appendChild(node);
            dots.push(node);
        }
        let currentDot = 0;

        window.addEventListener("mousemove", event => {
            let dot = dots[currentDot];
            dot.style.left = (event.pageX - 3) + "px";
            dot.style.top = (event.pageY - 3) + "px";
            currentDot = (currentDot + 1) % dots.length;
        });
    </script>
</body>

</html>